<template>
	<view class="password">
		<view class="a1">
			<text>旧密码：</text>
			<input type="text" placeholder="请输入旧密码" v-model="oldPassword"/>
		</view>
		<u-line></u-line>
		<view class="a1">
			<text>新密码：</text>
			<input type="password" placeholder="请输入新密码" v-model="newPassword"/>
		</view>
		<u-line></u-line>
		<u-button type="error" text="提交" :plain="true" @click="pass"></u-button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				oldPassword:'',
				newPassword:''
			}
		},
		methods: {
			pass(){
				if(this.oldPassword===''||this.newPassword===''){
					uni.showToast({
						title:'参数错误',
						icon:'error'
					})
					return
				}else{
					const password={
						oldPassword:this.oldPassword,
						newPassword:this.newPassword
					}
					this.api.get('/prod-api/api/common/user/resetPwd','PUT',password).then(res=>{
						if(res.data.code===200){
							setTimeout(function(){
								uni.showToast({
									title:'修改成功'
								})
							},700)
							uni.removeStorageSync('token_j')
							uni.removeStorageSync('login')
							uni.reLaunch({
								url:'/pages/login/login'
							})
						}else{
							setTimeout(function(){
								uni.showToast({
									title:'修改失败',
									icon:'error'
								})
							},700)
						}
					})
				}
			}
		}
	}
</script>

<style lang="scss">
.a1{
	display: flex;
	margin-top:20px;
	margin-bottom: 20px;
}
</style>
